package SwordOffer;

import java.util.Stack;

public class Sword_Offer_09 {

    private Stack<Integer> appendStack;
    private Stack<Integer> deleteStack;

    public Sword_Offer_09() {
        appendStack = new Stack<>();
        deleteStack = new Stack<>();
    }

    public void appendTail(int value) {
        appendStack.push(value);
    }

    public int deleteHead() {
        if (deleteStack.empty()) {
            while (!appendStack.empty()) {
                deleteStack.push(appendStack.pop());
            }
        }
        if (deleteStack.empty()) {
            return -1;
        }
        return deleteStack.pop();
    }

    public static void main(String[] args) {
        Sword_Offer_09 model = new Sword_Offer_09();
        model.appendTail(3);
        System.out.println(model.deleteHead());
        System.out.println(model.deleteHead());
        System.out.println(model.deleteHead());
    }
}
